<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>

  <style>
    .red {
      color: red;
    }
  </style>
</head>
<body>
  

  <div id="app">
    <p>{{msg}}</p>
    <ul>
      <li v-for="(item,index) in arr"
          @click='setRed(index)'
          :class='{red:currentindex === index}'
      >{{index}}---{{item}}</li>
      <!-- <li v-for="(item,index) in arr">{{item}}</li> -->
    </ul>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script>
    const app = new Vue({
      el:'#app',
      data:{
        msg:'hello vue',
        arr:['item1','item2','item3'],
        currentindex:0
      },
      methods:{
        setRed(index){
          this.currentindex = index;
        }
      }
    })
  </script>
</body>
</html>